package org.softmed.rest.server.xstream;

import groovy.lang.GroovyClassLoader;

import com.google.inject.Inject;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

public class XStreamManager {
	public static final String CHAR_SET = "UTF-8";
	// public static final String CHAR_SET = "ISO-8859-1";

	public static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\""
			+ CHAR_SET + "\" ?>";

	@Inject
	static GroovyClassLoader groovyClassLoader;

	public synchronized static XStream getXStream() {
		XStream streamer = new XStream(new DomDriver(CHAR_SET));
		streamer.setClassLoader(groovyClassLoader);
		return streamer;
	}

	public static GroovyClassLoader getGroovyClassLoader() {
		return groovyClassLoader;
	}

	public static void setGroovyClassLoader(GroovyClassLoader groovyClassLoader) {
		XStreamManager.groovyClassLoader = groovyClassLoader;
	}

}
